<#--
-- Build the attribute for sorting table
-- @param filter the filter
-- @return the attributes used in the URL
-->
<#function buildSortSearchAttribute filter>
	<#assign sortSearchAttribute = "" />
	<#if filter??>
		<#if filter.name?? && filter.name != "">
			<#assign sortSearchAttribute = sortSearchAttribute + "&amp;name=" + filter.name! />
		</#if>
		<#if filter.description?? && filter.description != "">
			<#assign sortSearchAttribute = sortSearchAttribute + "&amp;description=" + filter.description! />
		</#if>
		<#if filter.workgroup?? && filter.workgroup != "">
			<#assign sortSearchAttribute = sortSearchAttribute + "&amp;workgroup=" + filter.workgroup! />
		</#if>
	</#if>
	<#return sortSearchAttribute + "&amp;session=sesssion" />
</#function>

<div class="row-fluid">
	<div class="span12">
		<fieldset>
        <legend>#i18n{portal.mailinglist.manage_mailinglists.boxTitle}
			<span class="btn-group pull-right">
				<form class="form-inline" method="post"  action="jsp/admin/mailinglist/CreateMailingList.jsp">
					<button class="btn btn-primary btn-small pull-right" type="submit" >
						<i class="icon-plus icon-white" ></i>
							<span class="hidden-phone" >#i18n{portal.mailinglist.manage_mailinglists.buttonLabelCreate}</span>
                    </button>
                </form>
            </span>
        </legend>
        <div class="well well-small">
			<form class="form-search" method="post" name="search_mailinglist" action="jsp/admin/mailinglist/ManageMailingLists.jsp"  >
			<label for="name">#i18n{portal.mailinglist.manage_mailinglists.labelName}</label>
			<input type="text" id="name" name="name" value="${mailinglistFilter.name!}" maxlength="100" class="input-medium" />
			<label for="description" >#i18n{portal.mailinglist.manage_mailinglists.labelDescription}</label>
			<input type="text" id="description" name="description" value="${mailinglistFilter.description!}" maxlength="255"  class="input-xlarge" tabindex="2" />
			<button class="btn btn-primary btn-small" type="submit" ><i class="icon-search icon-white"></i>#i18n{portal.mailinglist.manage_mailinglists.buttonSearch}</button>
			</form>
	    </div>
        <@paginationAdmin paginator=paginator combo=1 />
    	<#assign sortSearchAttribute = buildSortSearchAttribute( mailinglistFilter! ) />
        <table class="table table-striped table-condensed">
			<tr>
				<th>#i18n{portal.mailinglist.manage_mailinglists.columnTitleName} <@sort jsp_url="jsp/admin/mailinglist/ManageMailingLists.jsp" attribute="name${sortSearchAttribute!}" /> </th>
				<th>#i18n{portal.mailinglist.manage_mailinglists.columnTitleDescription} <@sort jsp_url="jsp/admin/mailinglist/ManageMailingLists.jsp" attribute="description${sortSearchAttribute!}" /></th>
                <th>#i18n{portal.mailinglist.manage_mailinglists.columnTitleWorkgroup}</th>
				<th>#i18n{portal.mailinglist.manage_mailinglists.columnTitleActions}</th>
            </tr>
            <#list mailinglists_list as mailinglist>
            <tr>
				<td>${mailinglist.name}</a></td>
                <td>${mailinglist.description}</td>
                <td>${mailinglist.workgroup}</td>
                <td>
					<a class="btn btn-primary btn-small" href="jsp/admin/mailinglist/ModifyMailingList.jsp?id_mailinglist=${mailinglist.id}"  title="#i18n{portal.mailinglist.modify_mailinglist.buttonModify}" ><i class="icon-edit icon-white"></i></a>
                    <a class="btn btn-primary btn-small" href="jsp/admin/mailinglist/ViewUsers.jsp?id_mailinglist=${mailinglist.id}"  title="#i18n{portal.mailinglist.modify_mailinglist.linkLabelViewUsers}" ><i class="icon-user icon-white"></i></a>
                    <a class="btn btn-danger btn-small" href="jsp/admin/mailinglist/RemoveMailingList.jsp?id_mailinglist=${mailinglist.id}"  title="#i18n{portal.mailinglist.modify_mailinglist.linkLabelRemove}" ><i class="icon-trash icon-white"></i></a>
                </td>
            </tr>
            </#list>
        </table>
        <@paginationAdmin paginator=paginator />
    </div>
</div>